package io;

import java.io.Serializable;
import java.util.Arrays;

/*
  使用当前类测试对象流的序列化和反序列化

  JAVA BEAN 定义规范
  1:属性私有化
  2:为属性提供公开的GET SET方法
  3:定义无参构造器
  4:实现序列化接口

  凡是需要进行序列化的类都必须实现Serializable接口，同时该类中所有引用类型的属性也要实现该接口
  transient 关键字是忽略要序列化的属性  例:private transient String[] otherInfo; 意思是序列化时忽略此属性，除此之外关键字不起其他任何作用
 */
public class Person implements Serializable {
    public static final long serialVersionUID = 1L;
    private String name;
    private int age;
    private String sex;
    private String[] otherInfo;

    public Person() {

    }

    public Person(String name, int age, String sex, String[] otherInfo) {
        this.name = name;
        this.age = age;
        this.sex = sex;
        this.otherInfo = otherInfo;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", sex='" + sex + '\'' +
                ", otherInfo=" + Arrays.toString(otherInfo) +
                '}';
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String[] getOtherInfo() {
        return otherInfo;
    }

    public void setOtherInfo(String[] otherInfo) {
        this.otherInfo = otherInfo;
    }
}
